package com.example.a2212park


import com.amap.api.location.AMapLocationClient
import com.example.base.app.BaseApp
import com.example.db.RoomDBUtils
import com.facebook.drawee.backends.pipeline.Fresco
import com.squareup.picasso.Picasso
import dagger.hilt.android.HiltAndroidApp
import okhttp3.Headers
import okhttp3.Interceptor
import okhttp3.OkHttpClient

//App类
@HiltAndroidApp
//,SingletonImageLoader.Factory
class ParkApp:BaseApp() {
    override fun onCreate() {
        super.onCreate()
        //初始化Picasso
        Picasso.setSingletonInstance(Picasso.Builder(this).build())
        Fresco.initialize(this)
        //初始化数据库
        RoomDBUtils.initRoom(this)
        AMapLocationClient.updatePrivacyShow(this, true, true)
        AMapLocationClient.updatePrivacyAgree(this, true)
    }

//    override fun newImageLoader(context: PlatformContext): ImageLoader {
//        return ImageLoader.Builder(context)
//            .crossfade(true)
//            .components {
//                add(
//                    OkHttpNetworkFetcherFactory(
//                        callFactory = {
//                            OkHttpClient().newBuilder()
//                                .addNetworkInterceptor(Interceptor{
//                                    val headers = Headers.Builder() .set("Cache-Control","no-cache").build()
//                                    val request =it.request().newBuilder().headers(headers).build()
//                                    it.proceed(request)
//                                })
//                                .build()
//                        }
//                    )
//                )
//            }
//            .build()
//    }
}